<template>
  <div class="app-container">
    <el-table v-loading="loading" :data="hotList">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="商品id" align="center" prop="id" />
      <el-table-column label="商品图片" align="center" prop="image" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.image" :width="50" :height="50" />
        </template>
      </el-table-column>
      <el-table-column label="商品名称" align="center" prop="goodsName" />
      <el-table-column label="分类名称" align="center" prop="sortId">
        <template slot-scope="scope">
          <div v-for="(item,index)  in sorts" :key="index">
            <span type="success" v-if="scope.row.sortId ==item.sortId">
              {{item.sortName}}
            </span>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="商品价格" align="center" prop="goodsPrice" />
      <el-table-column label="销量" align="center" prop="sales" />
      <el-table-column label="库存" align="center" prop="stock" />
      <el-table-column label="商品类型" align="center" prop="goodsType">
        <template slot-scope="scope">
          <el-tag type="parimary" v-if="scope.row.goodsType ==null||scope.row.goodsType ==0">普通商品</el-tag>
          <el-tag type="warning" v-else>积分商品</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="上架状态" align="center" prop="isShow">
        <template slot-scope="scope">
          <el-tag type="success" v-if="scope.row.isShow == 0">上架</el-tag>
          <el-tag type="danger" v-else>下架</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="返回积分" align="center" prop="giveIntegral" />
      <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['goods:goods:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
            v-hasPermi="['goods:goods:remove']">删除</el-button>
        </template>
      </el-table-column> -->
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
  </div>
</template>
<script>
import { selectHot } from "@/api/goods/goods";
import { listSort, getSort } from "@/api/goods/sort";
export default {
  data () {
    return {
      hotList: [],
      total: 0,
      sorts: [],
      loading: false,
      showSearch: true,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
    }
  },

  methods: {
    getList () {
      selectHot(this.queryParams).then(response => {
        this.hotList = response.rows
        this.total = response.total;
      })
    },
    getSort () {
      listSort().then(res => {
        this.sorts = res.rows
        console.log(this.sorts)
      })
    },
    handleQuery () {

    },
    resetQuery () {

    },
    handleUpdate () {

    },
    handleDelete () {

    }
  },
  created () {
    this.getList()
    this.getSort()
  },
}
</script>